﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SearchCritetia.ascx.cs" Inherits="UC_SearchCritetia" %>

<%--<%@ Register TagPrefix="mp" TagName="CRMMAster" Src="~/MasterCRM.master" %>--%>
<%@ Register src="WaterMarkedTextBox.ascx" tagname="WaterMarkedTextBox" tagprefix="uc" %>
<%@ Register src="DatePickerUC.ascx" tagname="DatePickerUC" tagprefix="uc" %>

<script language="javascript" type="text/javascript">
    function rsPeriod_Click(sender,containerID) {


        var disabled = sender.checked;
       //x
        
        switch (containerID) {
            case "divMonthYear":
                enableDivMonthYear(!disabled);
                enableDivDay(disabled)
                enableDivDateRange(disabled)
                break;
            case "divDay":
                enableDivMonthYear(disabled);
                enableDivDay(!disabled)
                enableDivDateRange(disabled)
                break;
            case "divDateRange":
                enableDivMonthYear(disabled);
                enableDivDay(disabled)
                enableDivDateRange(!disabled)
                break;        
        }
    }

    function enableDivMonthYear(enabled) {
        var panel = document.getElementById("divMonthYear");
        var ddls;
        var validators;
        var input;       

        if (panel != null) {
            ddls = panel.getElementsByTagName("select");
            //validators = panel.getElementsByTagName("span");
            inputs = panel.getElementsByTagName("input");

            if (ddls != null && ddls.length > 0) {
                for (var i = 0; i < ddls.length; i++) {
                    ddls[i].disabled = enabled;
                }
            }

            if (validators != null && validators.length > 0) {
                for (var i = 0; i < validators.length; i++) {
                    validators[i].disabled = enabled;
                    //validators[i].enabled = !enabled;
                    ValidatorEnable(validators[i], !enabled);
                }
            }

            if (inputs != null && inputs.length > 0) {
                for (var i = 0; i < inputs.length; i++) {                   
                    inputs[i].disabled = enabled;                    
                }
            }

        }
    }

    function enableDivDay( enabled) {
        var panel = document.getElementById("divDay");
        var ddls;
        //var validators;
        if (panel != null) {
            ddls = panel.getElementsByTagName("select");
            validators = panel.getElementsByTagName("span");            

            if (ddls != null && ddls.length > 0) {
                for (var i = 0; i < ddls.length; i++) {
                    ddls[i].disabled = enabled;
                }
            }
           

            if (validators != null && validators.length > 0) {
                for (var i = 0; i < validators.length; i++) {
                    validators[i].disabled = enabled;
                    //validators[i].enabled = !enabled;
                    ValidatorEnable(validators[i], !enabled);
                }
            }
        }

    }

    function enableDivDateRange(enabled) {

        var panel = document.getElementById("divDateRange");
        var inputs;
        //var validators;
        var divs;
        if (panel != null) {
            inputs = panel.getElementsByTagName("input");
            validators = panel.getElementsByTagName("span");
            divs = panel.getElementsByTagName("div");

            if (divs != null && divs.length > 0) {
                for (var i = 0; i < divs.length; i++) {
                    divs[i].disabled = enabled;
                }
            }

            if (inputs != null && inputs.length > 0) {
                for (var i = 0; i < inputs.length; i++) {
                        inputs[i].disabled = enabled;
                }
            }

            if (validators != null && validators.length > 0) {
                for (var i = 0; i < validators.length; i++) {
                    validators[i].disabled = enabled;
                    //validators[i].enabled = !enabled;
                    ValidatorEnable(validators[i], !enabled);
                }
            }
        }


    }
</script>

<table width="100%">
  <tr>
    <td>
      <asp:Panel runat="server" id="searchCriteria" DefaultButton="btnSearch">
        <asp:Panel ID="pnlCallID" runat="server"><uc:WaterMarkedTextBox ID="txtCallID" runat="server" Caption="Call No."  /></asp:Panel>        
        
        <asp:Panel ID="pnlCustomerName" runat="server"><uc:WaterMarkedTextBox ID="txtCustomerName" runat="server" Caption="Customer Name"  /></asp:Panel>
        <asp:Panel ID="pnlAddress" runat="server"><uc:WaterMarkedTextBox ID="txtAddress" runat="server" Caption="Address" /></asp:Panel>
        <asp:Panel ID="pnlZipCode" runat="server"><uc:WaterMarkedTextBox ID="txtZipCode" runat="server" Caption="Zip Code" /></asp:Panel>
        <asp:Panel ID="pnlContactNo" runat="server"><uc:WaterMarkedTextBox ID="txtContactNo" runat="server" Caption="Contact No" /></asp:Panel>
        
        <asp:Panel ID="pnlACModel" runat="server"><uc:WaterMarkedTextBox ID="txtACModel" runat="server" Caption="AC Model" /></asp:Panel>
        <asp:Panel ID="pnlACSerialNo" runat="server"><uc:WaterMarkedTextBox ID="txtACSerialNo" runat="server" Caption="AC Serial No." /></asp:Panel>
        <asp:Panel ID="pnlACBrand" runat="server"><asp:DropDownList ID="ddlACBrands" runat="server"  AutoPostBack="false" style="width:auto;"></asp:DropDownList></asp:Panel>
        <asp:Panel ID="pnlMonth" runat="server">
            <asp:RadioButton  id="rdMonthYear" runat="server" GroupName="rdPeriod" Checked="true" onclick="rsPeriod_Click(this,'divMonthYear')" />            
            <div id="divMonthYear">            
                <asp:DropDownList ID="ddlMonth" runat="server" EnableViewState="true"></asp:DropDownList>
                <asp:Label ID="lblMonthReq" runat="server" Visible="true" CssClass="error" >*</asp:Label>
                <asp:RequiredFieldValidator ID="reqMonth" runat="server" ControlToValidate="ddlMonth" InitialValue="0" SetFocusOnError="true" 
                CssClass="error" Text="Req" Enabled="false" ErrorMessage="Req" ValidationGroup="submit" ></asp:RequiredFieldValidator>
                
                <uc:WaterMarkedTextBox ID="txtYear" runat="server" Caption="Year"/>                
            </div>
                      
            <asp:RadioButton  id="rdDay" runat="server" GroupName="rdPeriod" onclick="rsPeriod_Click(this,'divDay')" />
            <div id="divDay">           
                <asp:DropDownList ID="ddlDay" runat="server" EnableViewState="true" Enabled="false"></asp:DropDownList>
                <%--<asp:Label ID="lblDayReq" runat="server" Visible="false" CssClass="error" >*</asp:Label>
                <asp:RequiredFieldValidator ID="reqDay" runat="server" ControlToValidate="ddlDay" InitialValue="0" SetFocusOnError="true" 
                CssClass="error" Text="Req" ErrorMessage="Req" Enabled="false"  ValidationGroup="submit" ></asp:RequiredFieldValidator>--%>
            </div>
             
             <asp:RadioButton  id="rdDateRange" runat="server" GroupName="rdPeriod" onclick="rsPeriod_Click(this,'divDateRange')" />
            <div id="divDateRange">
                <uc:DatePickerUC ID="dtFromDate" runat="server" Enabled="false"  WatermarkText="From Date" />
                <uc:DatePickerUC ID="dtToDate" runat="server"  Enabled="false"  WatermarkText="To Date" />
            </div>
        </asp:Panel>
        <asp:Panel ID="pnlDelaer" runat="server">
          <asp:DropDownList ID="ddlDealer" runat="server" AutoPostBack="false" style="width:auto;"></asp:DropDownList>
          <asp:Label  ID="lblDlrReq" runat="server" Visible="false" CssClass="error" >*</asp:Label>
          <asp:RequiredFieldValidator ID="reqDealer" runat="server" ControlToValidate="ddlDealer" InitialValue="0" SetFocusOnError="true" 
            CssClass="error" Text="Req" ErrorMessage="Req" Enabled="false" Visible="false" ValidationGroup="submit" ></asp:RequiredFieldValidator>
        </asp:Panel>
        <asp:Panel ID="pnlCounter" runat="server">
          <asp:DropDownList ID="ddlCounter" runat="server"  AutoPostBack="false" style="width:auto;"></asp:DropDownList>
          <asp:Label  ID="lblCounterReq" runat="server"  Visible="false" CssClass="error" >*</asp:Label>
          <asp:RequiredFieldValidator ID="reqCounter" runat="server" ControlToValidate="pnlCounter" InitialValue="0" SetFocusOnError="true" 
            CssClass="error" Text="Req" ErrorMessage="Req" Enabled="false" Visible="false" ValidationGroup="submit" ></asp:RequiredFieldValidator>
        </asp:Panel>
        <asp:Panel ID="pnlStatus" runat="server">
          <asp:DropDownList ID="ddlStatus" runat="server" EnableViewState="true"></asp:DropDownList>
        </asp:Panel>
        <asp:Panel ID="pnlCalltype" runat="server">
          <asp:DropDownList ID="ddlCallType" runat="server">
            <asp:ListItem Value="0">--Select--</asp:ListItem>
            <asp:ListItem Value="1">Regular</asp:ListItem>
            <asp:ListItem Value="2">Free</asp:ListItem>
            <asp:ListItem Value="3">Total Free</asp:ListItem>
          </asp:DropDownList>
        </asp:Panel>
        <asp:Panel ID="pnlInstaller" runat="server"><asp:DropDownList ID="ddlInstaller" runat="server"></asp:DropDownList></asp:Panel>
        
        <asp:Panel ID="pnlIsStrict" runat="server"><asp:CheckBox ID="chkIsStrict" runat="server" Checked="true" Text="Is Strict" /></asp:Panel>
        <asp:Panel ID="pnlTempClosed" runat="server"><asp:CheckBox ID="chkIsTempClosed" runat="server" Text="Is Temp Closed" /></asp:Panel>
        <asp:Panel ID="pnlSubmitButton" runat="server">
          <asp:Button ID="btnSearch" runat="server" Text="Search" ValidationGroup="submit" onclick="btnSearch_Click" style=" width:80px" />
        </asp:Panel>
      </asp:Panel>
    </td>
  </tr>
</table>
